#include "bsp/bsp.h"
#include "bsp/bsp_debug.h"
#include "bsp/bsp_delay.h"
#include "bsp/bsp_led.h"
#include "includes.h"
#include "libs/mimxrt1052/fsl_phy_83848.h"
#include "lwip/api.h"
#include "lwip/init.h"
void testPHY() {
  enet_config_t enet_config;
  uint32_t sys_clock;
	status_t status;

  const clock_enet_pll_config_t pll_config = {.enableClkOutput = true, .enableClkOutput25M = false, .loopDivider = 1};
  CLOCK_InitEnetPll(&pll_config);

  ENET_GetDefaultConfig(&enet_config);

  sys_clock =  CLOCK_GetFreq(kCLOCK_CoreSysClk);

  debug_info("sysclock %d\r\n",sys_clock);

		status = PHY_Init(ENET,1,sys_clock);
		debug_info("phy initilized %d\r\n",status);

}

int main() {
  bsp_init();
  bsp_debug_init();
  debug_init(bsp_debug_stream, DEBUG_ALL);
  bsp_led_init();
  debug_info("\r\n");
  debug_info("System startup");
  // while

  //lwip_init();
  // netif_add()

  //testPHY();

  while (1) {
    debug_info("LED blink");
    bsp_led_on(0);
    bsp_delay_ms(500);
    bsp_led_off(0);
    bsp_delay_ms(500);
    bsp_led_toggle(0);
    bsp_delay_ms(500);
    bsp_led_toggle(0);
    bsp_delay_ms(500);
  }
}